home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: n4jvp@ix.netcom.com (n4jvp)
- Newsgroups: comp.lang.c++
- Subject: Re: Fishing for Opinions: Global Variables in GUI
- Date: Fri, 12 Jan 1996 12:59:08 GMT
- Organization: Netcom
- Message-ID: <30f657d7.2731554@ixnews1.ix.netcom.com>
- References: <4cjg9c$m92@crchh327.rich.bnr.ca> <4d3o7o$d9m@news.bridge.net>
- NNTP-Posting-Host: ix-nas-nh1-17.ix.netcom.com
- X-NETCOM-Date: Fri Jan 12 5:01:06 AM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- To avoid using globals in multi-module programs I have been
- using the extern keyword within the specific functions needing access
- to the globals i.e.
-
- void foo()
- {
- ....
- }
-
- int bar(int num)
- {
- extern Square * Sfirst;
- ....
- }
-
- I find that in addition to making the code easier to follow, if I wish
- to move bar() from one module to another I don't have to worry if the
- Square * is global to that module. I suppose I could pass the pointer
- as an argument but some of the functions that call bar() do not have
- scope access to the Square *.
-
- Is this a good practice or is there a better way to do it?
-